<?php
namespace app\spadmin\controller\order;
use app\common\controller\Backend;
use think\Exception;
use think\Db;
/**
 * 充值订单
 */
class Recharge extends Backend{
    public function _initialize()
    {
        parent::_initialize();
        $this->model = model('OrderRecharge');

    }

    public function index(){
        $this->request->filter(['strip_tags', 'trim']);
        if($this->request->isAjax()){
            $data = $this->request->param();
            if (isset($data['keywords']) && $data['keywords']) {
                $map['o.order_sn|u.mobile'] = ['like', '%' . $data['keywords'] . '%'];
            }            
            if (isset($data['status']) && $data['status']) {
                $map['o.status'] = $data['status'];
            } else {
                $map['o.status'] = ['>',0];
            }
            $list =   $this->model->alias('o')->join('__USER__ u','u.id=o.user_id')->where($map)->order('o.id desc')->paginate($data['limit'])->toArray();

            return $this->result($list);
        }
        return $this->view->fetch();
    }
    public function edit($ids=null){
        $row = $this->model->alias('o')->join('__USER__ u','u.id=o.user_id')->where('o.id',$ids)->find();
        
        $this->assign('info',$row);
        return $this->view->fetch();
    }
}